
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, and Azure
-- --------------------------------------------------
-- Date Created: 11/03/2012 19:51:53
-- Generated from EDMX file: C:\Users\Johns\documents\visual studio 2012\Projects\CERT\CERT\DAL\Model1.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [NET];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_AgeRangeVictim]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[People_Victim] DROP CONSTRAINT [FK_AgeRangeVictim];
GO
IF OBJECT_ID(N'[dbo].[FK_GenderVictim]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[People_Victim] DROP CONSTRAINT [FK_GenderVictim];
GO
IF OBJECT_ID(N'[dbo].[FK_HazardTypesLocationHazards]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LocationHazards] DROP CONSTRAINT [FK_HazardTypesLocationHazards];
GO
IF OBJECT_ID(N'[dbo].[FK_IncidentLocation]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Locations] DROP CONSTRAINT [FK_IncidentLocation];
GO
IF OBJECT_ID(N'[dbo].[FK_LocationLocationHazards]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LocationHazards] DROP CONSTRAINT [FK_LocationLocationHazards];
GO
IF OBJECT_ID(N'[dbo].[FK_LocationLocationVictims]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LocationVictims] DROP CONSTRAINT [FK_LocationLocationVictims];
GO
IF OBJECT_ID(N'[dbo].[FK_LocationStatusesLocation]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Locations] DROP CONSTRAINT [FK_LocationStatusesLocation];
GO
IF OBJECT_ID(N'[dbo].[FK_LocationTeamRolesForLocation]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[TeamRolesForLocations] DROP CONSTRAINT [FK_LocationTeamRolesForLocation];
GO
IF OBJECT_ID(N'[dbo].[FK_LocationTypesLocation]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Locations] DROP CONSTRAINT [FK_LocationTypesLocation];
GO
IF OBJECT_ID(N'[dbo].[FK_PersonLocationVictims]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[LocationVictims] DROP CONSTRAINT [FK_PersonLocationVictims];
GO
IF OBJECT_ID(N'[dbo].[FK_TeamIncident]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Incidents] DROP CONSTRAINT [FK_TeamIncident];
GO
IF OBJECT_ID(N'[dbo].[FK_TeamMember_inherits_Person]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[People_TeamMember] DROP CONSTRAINT [FK_TeamMember_inherits_Person];
GO
IF OBJECT_ID(N'[dbo].[FK_TeamMemberTeamRolesForLocation]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[TeamRolesForLocations] DROP CONSTRAINT [FK_TeamMemberTeamRolesForLocation];
GO
IF OBJECT_ID(N'[dbo].[FK_TeamRolesTeamMember]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[People_TeamMember] DROP CONSTRAINT [FK_TeamRolesTeamMember];
GO
IF OBJECT_ID(N'[dbo].[FK_TeamRolesTeamRolesForLocation]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[TeamRolesForLocations] DROP CONSTRAINT [FK_TeamRolesTeamRolesForLocation];
GO
IF OBJECT_ID(N'[dbo].[FK_TeamTeamMember]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[People_TeamMember] DROP CONSTRAINT [FK_TeamTeamMember];
GO
IF OBJECT_ID(N'[dbo].[FK_Victim_inherits_Person]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[People_Victim] DROP CONSTRAINT [FK_Victim_inherits_Person];
GO
IF OBJECT_ID(N'[dbo].[FK_VictimStatusVictim]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[People_Victim] DROP CONSTRAINT [FK_VictimStatusVictim];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Incidents]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Incidents];
GO
IF OBJECT_ID(N'[dbo].[LocationHazards]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LocationHazards];
GO
IF OBJECT_ID(N'[dbo].[Locations]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Locations];
GO
IF OBJECT_ID(N'[dbo].[LocationVictims]', 'U') IS NOT NULL
    DROP TABLE [dbo].[LocationVictims];
GO
IF OBJECT_ID(N'[dbo].[Lookups]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Lookups];
GO
IF OBJECT_ID(N'[dbo].[People]', 'U') IS NOT NULL
    DROP TABLE [dbo].[People];
GO
IF OBJECT_ID(N'[dbo].[People_TeamMember]', 'U') IS NOT NULL
    DROP TABLE [dbo].[People_TeamMember];
GO
IF OBJECT_ID(N'[dbo].[People_Victim]', 'U') IS NOT NULL
    DROP TABLE [dbo].[People_Victim];
GO
IF OBJECT_ID(N'[dbo].[TeamRolesForLocations]', 'U') IS NOT NULL
    DROP TABLE [dbo].[TeamRolesForLocations];
GO
IF OBJECT_ID(N'[dbo].[Teams]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Teams];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'People'
CREATE TABLE [dbo].[People] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Name] nvarchar(100)  NULL,
    [Photo] varbinary(max)  NULL
);
GO

-- Creating table 'Incidents'
CREATE TABLE [dbo].[Incidents] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Title] nvarchar(100)  NULL,
    [DateOfIndicent] datetime  NOT NULL,
    [Team_Id] int  NOT NULL
);
GO

-- Creating table 'Teams'
CREATE TABLE [dbo].[Teams] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Title] nvarchar(100)  NOT NULL,
    [Graphic] varbinary(max)  NULL,
    [Color] nvarchar(11)  NULL
);
GO

-- Creating table 'Locations'
CREATE TABLE [dbo].[Locations] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [LocationTypeId] int  NOT NULL,
    [Photo] varbinary(max)  NULL,
    [Street] nvarchar(100)  NULL,
    [City] nvarchar(100)  NULL,
    [Zip] nvarchar(5)  NULL,
    [StartTime] datetime  NOT NULL,
    [EndTime] datetime  NOT NULL,
    [EndStatusID] int  NULL,
    [GeoLocationLong] decimal(18,0)  NULL,
    [GeoLocationLat] decimal(18,0)  NULL,
    [IncidentId] int  NOT NULL
);
GO

-- Creating table 'LocationVictims'
CREATE TABLE [dbo].[LocationVictims] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [VictimId] int  NOT NULL,
    [LocationId] int  NOT NULL
);
GO

-- Creating table 'LocationHazards'
CREATE TABLE [dbo].[LocationHazards] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [HazardTypeID] int  NOT NULL,
    [LocationID] int  NOT NULL
);
GO

-- Creating table 'TeamRolesForLocations'
CREATE TABLE [dbo].[TeamRolesForLocations] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [TeamRoleForLocationID] int  NOT NULL,
    [LocationID] int  NOT NULL,
    [TeamMemberID] int  NOT NULL
);
GO

-- Creating table 'Lookups'
CREATE TABLE [dbo].[Lookups] (
    [Title] nvarchar(100)  NOT NULL,
    [Icon] varbinary(max)  NULL,
    [Color] nvarchar(100)  NULL,
    [LookupTypeID] int  NOT NULL,
    [LookupID] int IDENTITY(1,1) NOT NULL,
    [Discriminator] nvarchar(100)  NULL
);
GO

-- Creating table 'People_TeamMember'
CREATE TABLE [dbo].[People_TeamMember] (
    [Email] nvarchar(150)  NULL,
    [Phone] nvarchar(10)  NULL,
    [PhoneExtension] nvarchar(5)  NULL,
    [DefaultTeamRoleId] int  NULL,
    [TeamId] int  NOT NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'People_Victim'
CREATE TABLE [dbo].[People_Victim] (
    [GenderID] int  NULL,
    [AgeRangeID] int  NULL,
    [VictimStatusID] int  NULL,
    [Id] int  NOT NULL
);
GO

-- Creating table 'Lookups_TeamRoles'
CREATE TABLE [dbo].[Lookups_TeamRoles] (
    [LookupID] int  NOT NULL
);
GO

-- Creating table 'VictimStatus'
CREATE TABLE [dbo].[VictimStatus] (
    [LookupID] int  NOT NULL
);
GO

-- Creating table 'AgeRange'
CREATE TABLE [dbo].[AgeRange] (
    [LookupID] int  NOT NULL
);
GO

-- Creating table 'Gender'
CREATE TABLE [dbo].[Gender] (
    [LookupID] int  NOT NULL
);
GO

-- Creating table 'LocationStatuses'
CREATE TABLE [dbo].[LocationStatuses] (
    [LookupID] int  NOT NULL
);
GO

-- Creating table 'LocationTypes'
CREATE TABLE [dbo].[LocationTypes] (
    [LookupID] int  NOT NULL
);
GO

-- Creating table 'HazardType'
CREATE TABLE [dbo].[HazardType] (
    [LookupID] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'People'
ALTER TABLE [dbo].[People]
ADD CONSTRAINT [PK_People]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Incidents'
ALTER TABLE [dbo].[Incidents]
ADD CONSTRAINT [PK_Incidents]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Teams'
ALTER TABLE [dbo].[Teams]
ADD CONSTRAINT [PK_Teams]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Locations'
ALTER TABLE [dbo].[Locations]
ADD CONSTRAINT [PK_Locations]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'LocationVictims'
ALTER TABLE [dbo].[LocationVictims]
ADD CONSTRAINT [PK_LocationVictims]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'LocationHazards'
ALTER TABLE [dbo].[LocationHazards]
ADD CONSTRAINT [PK_LocationHazards]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'TeamRolesForLocations'
ALTER TABLE [dbo].[TeamRolesForLocations]
ADD CONSTRAINT [PK_TeamRolesForLocations]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [LookupID] in table 'Lookups'
ALTER TABLE [dbo].[Lookups]
ADD CONSTRAINT [PK_Lookups]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- Creating primary key on [Id] in table 'People_TeamMember'
ALTER TABLE [dbo].[People_TeamMember]
ADD CONSTRAINT [PK_People_TeamMember]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'People_Victim'
ALTER TABLE [dbo].[People_Victim]
ADD CONSTRAINT [PK_People_Victim]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [LookupID] in table 'Lookups_TeamRoles'
ALTER TABLE [dbo].[Lookups_TeamRoles]
ADD CONSTRAINT [PK_Lookups_TeamRoles]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- Creating primary key on [LookupID] in table 'VictimStatus'
ALTER TABLE [dbo].[VictimStatus]
ADD CONSTRAINT [PK_VictimStatus]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- Creating primary key on [LookupID] in table 'AgeRange'
ALTER TABLE [dbo].[AgeRange]
ADD CONSTRAINT [PK_AgeRange]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- Creating primary key on [LookupID] in table 'Gender'
ALTER TABLE [dbo].[Gender]
ADD CONSTRAINT [PK_Gender]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- Creating primary key on [LookupID] in table 'LocationStatuses'
ALTER TABLE [dbo].[LocationStatuses]
ADD CONSTRAINT [PK_LocationStatuses]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- Creating primary key on [LookupID] in table 'LocationTypes'
ALTER TABLE [dbo].[LocationTypes]
ADD CONSTRAINT [PK_LocationTypes]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- Creating primary key on [LookupID] in table 'HazardType'
ALTER TABLE [dbo].[HazardType]
ADD CONSTRAINT [PK_HazardType]
    PRIMARY KEY CLUSTERED ([LookupID] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [TeamId] in table 'People_TeamMember'
ALTER TABLE [dbo].[People_TeamMember]
ADD CONSTRAINT [FK_TeamTeamMember]
    FOREIGN KEY ([TeamId])
    REFERENCES [dbo].[Teams]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TeamTeamMember'
CREATE INDEX [IX_FK_TeamTeamMember]
ON [dbo].[People_TeamMember]
    ([TeamId]);
GO

-- Creating foreign key on [Team_Id] in table 'Incidents'
ALTER TABLE [dbo].[Incidents]
ADD CONSTRAINT [FK_TeamIncident]
    FOREIGN KEY ([Team_Id])
    REFERENCES [dbo].[Teams]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TeamIncident'
CREATE INDEX [IX_FK_TeamIncident]
ON [dbo].[Incidents]
    ([Team_Id]);
GO

-- Creating foreign key on [IncidentId] in table 'Locations'
ALTER TABLE [dbo].[Locations]
ADD CONSTRAINT [FK_IncidentLocation]
    FOREIGN KEY ([IncidentId])
    REFERENCES [dbo].[Incidents]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_IncidentLocation'
CREATE INDEX [IX_FK_IncidentLocation]
ON [dbo].[Locations]
    ([IncidentId]);
GO

-- Creating foreign key on [LocationId] in table 'LocationVictims'
ALTER TABLE [dbo].[LocationVictims]
ADD CONSTRAINT [FK_LocationLocationVictims]
    FOREIGN KEY ([LocationId])
    REFERENCES [dbo].[Locations]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LocationLocationVictims'
CREATE INDEX [IX_FK_LocationLocationVictims]
ON [dbo].[LocationVictims]
    ([LocationId]);
GO

-- Creating foreign key on [LocationID] in table 'LocationHazards'
ALTER TABLE [dbo].[LocationHazards]
ADD CONSTRAINT [FK_LocationLocationHazards]
    FOREIGN KEY ([LocationID])
    REFERENCES [dbo].[Locations]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LocationLocationHazards'
CREATE INDEX [IX_FK_LocationLocationHazards]
ON [dbo].[LocationHazards]
    ([LocationID]);
GO

-- Creating foreign key on [VictimId] in table 'LocationVictims'
ALTER TABLE [dbo].[LocationVictims]
ADD CONSTRAINT [FK_PersonLocationVictims]
    FOREIGN KEY ([VictimId])
    REFERENCES [dbo].[People_Victim]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_PersonLocationVictims'
CREATE INDEX [IX_FK_PersonLocationVictims]
ON [dbo].[LocationVictims]
    ([VictimId]);
GO

-- Creating foreign key on [DefaultTeamRoleId] in table 'People_TeamMember'
ALTER TABLE [dbo].[People_TeamMember]
ADD CONSTRAINT [FK_TeamRolesTeamMember]
    FOREIGN KEY ([DefaultTeamRoleId])
    REFERENCES [dbo].[Lookups_TeamRoles]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TeamRolesTeamMember'
CREATE INDEX [IX_FK_TeamRolesTeamMember]
ON [dbo].[People_TeamMember]
    ([DefaultTeamRoleId]);
GO

-- Creating foreign key on [LocationID] in table 'TeamRolesForLocations'
ALTER TABLE [dbo].[TeamRolesForLocations]
ADD CONSTRAINT [FK_LocationTeamRolesForLocation]
    FOREIGN KEY ([LocationID])
    REFERENCES [dbo].[Locations]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LocationTeamRolesForLocation'
CREATE INDEX [IX_FK_LocationTeamRolesForLocation]
ON [dbo].[TeamRolesForLocations]
    ([LocationID]);
GO

-- Creating foreign key on [TeamRoleForLocationID] in table 'TeamRolesForLocations'
ALTER TABLE [dbo].[TeamRolesForLocations]
ADD CONSTRAINT [FK_TeamRolesTeamRolesForLocation]
    FOREIGN KEY ([TeamRoleForLocationID])
    REFERENCES [dbo].[Lookups_TeamRoles]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TeamRolesTeamRolesForLocation'
CREATE INDEX [IX_FK_TeamRolesTeamRolesForLocation]
ON [dbo].[TeamRolesForLocations]
    ([TeamRoleForLocationID]);
GO

-- Creating foreign key on [TeamMemberID] in table 'TeamRolesForLocations'
ALTER TABLE [dbo].[TeamRolesForLocations]
ADD CONSTRAINT [FK_TeamMemberTeamRolesForLocation]
    FOREIGN KEY ([TeamMemberID])
    REFERENCES [dbo].[People_TeamMember]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_TeamMemberTeamRolesForLocation'
CREATE INDEX [IX_FK_TeamMemberTeamRolesForLocation]
ON [dbo].[TeamRolesForLocations]
    ([TeamMemberID]);
GO

-- Creating foreign key on [VictimStatusID] in table 'People_Victim'
ALTER TABLE [dbo].[People_Victim]
ADD CONSTRAINT [FK_VictimStatusVictim]
    FOREIGN KEY ([VictimStatusID])
    REFERENCES [dbo].[VictimStatus]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_VictimStatusVictim'
CREATE INDEX [IX_FK_VictimStatusVictim]
ON [dbo].[People_Victim]
    ([VictimStatusID]);
GO

-- Creating foreign key on [AgeRangeID] in table 'People_Victim'
ALTER TABLE [dbo].[People_Victim]
ADD CONSTRAINT [FK_AgeRangeVictim]
    FOREIGN KEY ([AgeRangeID])
    REFERENCES [dbo].[AgeRange]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_AgeRangeVictim'
CREATE INDEX [IX_FK_AgeRangeVictim]
ON [dbo].[People_Victim]
    ([AgeRangeID]);
GO

-- Creating foreign key on [GenderID] in table 'People_Victim'
ALTER TABLE [dbo].[People_Victim]
ADD CONSTRAINT [FK_GenderVictim]
    FOREIGN KEY ([GenderID])
    REFERENCES [dbo].[Gender]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_GenderVictim'
CREATE INDEX [IX_FK_GenderVictim]
ON [dbo].[People_Victim]
    ([GenderID]);
GO

-- Creating foreign key on [EndStatusID] in table 'Locations'
ALTER TABLE [dbo].[Locations]
ADD CONSTRAINT [FK_LocationStatusesLocation]
    FOREIGN KEY ([EndStatusID])
    REFERENCES [dbo].[LocationStatuses]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LocationStatusesLocation'
CREATE INDEX [IX_FK_LocationStatusesLocation]
ON [dbo].[Locations]
    ([EndStatusID]);
GO

-- Creating foreign key on [LocationTypeId] in table 'Locations'
ALTER TABLE [dbo].[Locations]
ADD CONSTRAINT [FK_LocationTypesLocation]
    FOREIGN KEY ([LocationTypeId])
    REFERENCES [dbo].[LocationTypes]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_LocationTypesLocation'
CREATE INDEX [IX_FK_LocationTypesLocation]
ON [dbo].[Locations]
    ([LocationTypeId]);
GO

-- Creating foreign key on [HazardTypeID] in table 'LocationHazards'
ALTER TABLE [dbo].[LocationHazards]
ADD CONSTRAINT [FK_HazardTypesLocationHazards]
    FOREIGN KEY ([HazardTypeID])
    REFERENCES [dbo].[HazardType]
        ([LookupID])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_HazardTypesLocationHazards'
CREATE INDEX [IX_FK_HazardTypesLocationHazards]
ON [dbo].[LocationHazards]
    ([HazardTypeID]);
GO

-- Creating foreign key on [Id] in table 'People_TeamMember'
ALTER TABLE [dbo].[People_TeamMember]
ADD CONSTRAINT [FK_TeamMember_inherits_Person]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[People]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Id] in table 'People_Victim'
ALTER TABLE [dbo].[People_Victim]
ADD CONSTRAINT [FK_Victim_inherits_Person]
    FOREIGN KEY ([Id])
    REFERENCES [dbo].[People]
        ([Id])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LookupID] in table 'Lookups_TeamRoles'
ALTER TABLE [dbo].[Lookups_TeamRoles]
ADD CONSTRAINT [FK_TeamRoles_inherits_Lookup]
    FOREIGN KEY ([LookupID])
    REFERENCES [dbo].[Lookups]
        ([LookupID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LookupID] in table 'VictimStatus'
ALTER TABLE [dbo].[VictimStatus]
ADD CONSTRAINT [FK_VictimStatus_inherits_Lookup]
    FOREIGN KEY ([LookupID])
    REFERENCES [dbo].[Lookups]
        ([LookupID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LookupID] in table 'AgeRange'
ALTER TABLE [dbo].[AgeRange]
ADD CONSTRAINT [FK_AgeRange_inherits_Lookup]
    FOREIGN KEY ([LookupID])
    REFERENCES [dbo].[Lookups]
        ([LookupID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LookupID] in table 'Gender'
ALTER TABLE [dbo].[Gender]
ADD CONSTRAINT [FK_Gender_inherits_Lookup]
    FOREIGN KEY ([LookupID])
    REFERENCES [dbo].[Lookups]
        ([LookupID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LookupID] in table 'LocationStatuses'
ALTER TABLE [dbo].[LocationStatuses]
ADD CONSTRAINT [FK_LocationStatuses_inherits_Lookup]
    FOREIGN KEY ([LookupID])
    REFERENCES [dbo].[Lookups]
        ([LookupID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LookupID] in table 'LocationTypes'
ALTER TABLE [dbo].[LocationTypes]
ADD CONSTRAINT [FK_LocationTypes_inherits_Lookup]
    FOREIGN KEY ([LookupID])
    REFERENCES [dbo].[Lookups]
        ([LookupID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- Creating foreign key on [LookupID] in table 'HazardType'
ALTER TABLE [dbo].[HazardType]
ADD CONSTRAINT [FK_HazardTypes_inherits_Lookup]
    FOREIGN KEY ([LookupID])
    REFERENCES [dbo].[Lookups]
        ([LookupID])
    ON DELETE CASCADE ON UPDATE NO ACTION;
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------